package br.com.leilao.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import br.com.leilao.util.ConstantsBD;

@Entity
@Table(name = ConstantsBD.DATABASE_TABLE_USUARIO)
public class Usuario implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int idUsuario;

	@Column(name = "cpf", unique = true, insertable = true, updatable = true, length = 14)
	private String cpf;

	@Column(name = "nome", insertable = true, updatable = true, length = 50)
	private String nome;

	@Column(name = "email", insertable = true, updatable = true, length = 50)
	private String email;

	@Column(name = "login", unique = true, insertable = true, updatable = true, length = 20)
	private String login;

	@Column(name = "senha", insertable = true, updatable = true, length = 20)
	private String senha;

	@Column(name = "sexo", insertable = true, updatable = true, length = 1)
	private char sexo;

	 @ManyToOne
	 @Fetch(FetchMode.JOIN)
	 @JoinColumn(referencedColumnName = "idPerfil")
	private Perfil perfil;
	
	public Usuario() {

	}

	public Usuario(int idUsuario, String cpf, String nome, String email,
			String login, String senha, char sexo, Perfil perfil) {
		super();
		this.idUsuario = idUsuario;
		this.cpf = cpf;
		this.nome = nome;
		this.email = email;
		this.login = login;
		this.senha = senha;
		this.sexo = sexo;
		this.perfil = perfil;
	}

	public char getSexo() {
		return sexo;
	}

	public void setSexo(char sexo) {
		this.sexo = sexo;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getSenha() {
		return senha;
	}

	public void setSenha(String senha) {
		this.senha = senha;
	}

	public int getIdUsuario() {
		return idUsuario;
	}

	public void setIdUsuario(int id) {
		this.idUsuario = id;
	}

	public String getCpf() {
		return cpf;
	}

	public void setCpf(String cpf) {
		this.cpf = cpf;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String none) {
		this.nome = none;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	public Perfil getPerfil() {
		return perfil;
	}
	
	public void setPerfil(Perfil perfil) {
		this.perfil = perfil;
	}

}
